package com.itheima.Properties集合;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
import java.util.Scanner;

public class PropertiesDemo {
    public static void main(String[] args) throws IOException {
        //读取
        Properties prop = new Properties();
        FileReader fr = new FileReader("day623-24CharStream\\prop.properties");
        //调用完了load方法之后，文件中的键值对数据已经在集合中了
        prop.load(fr);

        //需求：模拟用户登录
        Scanner sc = new Scanner(System.in);
        System.out.printf("用户名:");
        String username = sc.next();
        System.out.printf("密码：");
        String password = sc.next();

        //匹配用户录入的用户名密码是否存在
        String realPassword = prop.getProperty(username);
        if (realPassword!=null&&realPassword.equals(password)){
            System.out.printf("登录成功");
        }else {
            System.out.printf("用户名或密码错误！");
        }
      //  System.out.printf(prop);
    }
}
